// createLogger是v3中vuex 的一个logger模块
import { createStore, createLogger } from 'vuex'
// 本地持久化
import createPersistedstate from 'vuex-persistedstate'
import user from './modules/user'
import cart from './modules/cart'
import category from './modules/category'

export default createStore({
  state: {
  },
  // vuex的计算属性
  getters: {
    token: state => {
      return state.user.profile.token
    }
  },
  mutations: {
  },
  actions: {
  },
  modules: {
    user,
    cart,
    category
  },
  plugins: [
    createPersistedstate({
      key: 'erabbit-client-pc-store',
      paths: ['user', 'cart'] // 需要本地持久化的模块
    }),
    createLogger()
  ]
})
